home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 8 / Revista CD Expert nº 08 CD1.iso / Utilitarios / Especiais / PhotoSuite II / DATA1.CAB / English_Resources / HTMLComponent / TempPSII / Common / Routing.js < prev    next >
Encoding:
JavaScript  |  1999-01-08  |  7.9 KB  |  385 lines

  1. ////////////////////////////////////////////////////////////////
  2. //
  3. //    Routing.js
  4. //
  5. //     Routing routine mapping for generic pages
  6. //
  7.  
  8. // Delete a routing (This will cascade up to Root.html)
  9. function DeleteRouting( Dest, FrameObject )
  10. {
  11.     return top._DeleteRouting( Dest, FrameObject );
  12. }
  13.  
  14. // Add a routing (This will cascade up to Root.html)
  15. function AddRouting( Dest, FrameObject, Dependants )
  16. {
  17.     return top._AddRouting( Dest, FrameObject, Dependants );
  18. }
  19.  
  20. // Route a function call (This will cascade up to Root.html)
  21. function RouteCall( Dest, EvalCode )
  22. {
  23.     return top._RouteCall( Dest, EvalCode );
  24. }
  25.  
  26. // Set Queueing mode (This will cascade up to Root.html)
  27. function SetQueueMode( Dest, Mode, Recurse )
  28. {
  29.     return top._SetQueueMode( Dest, Mode, Recurse );
  30. }
  31.  
  32. // Execute some code (called from Root.html)
  33. function EvalCode(MyCode)
  34. {
  35.     if( MyCode != "" )
  36.     {
  37.         return eval(MyCode);
  38.     }
  39. }
  40.  
  41. ////////////////////////////////////////////////////////////////
  42. //
  43. //    Simplified mappings
  44. //
  45.  
  46. // Roots
  47.  
  48. function GetLanguageFolder()
  49. {
  50.     // This is a hack for speed!
  51.     return top._GetLanguageFolder();
  52.     // Proper call should be:
  53.     // return top._RouteCall( "Root", "_GetLanguageFolder();" );
  54. }
  55.  
  56. function SetConsoleMode( Expert )
  57. {
  58.     // This is a hack for speed!
  59.     return top._SetConsoleMode( Expert );
  60.     // Proper call should be:
  61.     // return top._RouteCall( "Root", "_SetConsoleMode("+Expert+");" );
  62. }
  63.  
  64. // Liquid Toolkit (through proxies)
  65.  
  66. function LTKTriggerEvent(driver)
  67. {
  68.     return top._RouteCall( "Liquid", "_LTKTriggerEvent('"+driver+"');" );
  69. }
  70.  
  71. function LTKDoHelp()
  72. {
  73.     return top._RouteCall( "Liquid", "_LTKTriggerEvent('CommandDispatcher,Active,20140');" );
  74. }
  75.  
  76. function LTKConnectToWorkflow(wkf)
  77. {
  78.     return top._RouteCall( "Liquid", "_LTKConnectToWorkflow('"+wkf+"');" );
  79. }
  80.  
  81. function LTKDisconnectFromWorkflow(wkf)
  82. {
  83.     return top._RouteCall( "Liquid", "_LTKDisconnectFromWorkflow('"+wkf+"');" );
  84. }
  85.  
  86. function LTKGetContext( Ctx )
  87. {
  88.     return top._RouteCall( "Liquid", "_LTKGetContext("+Ctx+");" );
  89. }
  90.  
  91. function isMapi()
  92. {
  93.     return top._RouteCall( "Liquid", "_isMapi();" );
  94. }
  95.  
  96. function isPrinters()
  97. {
  98.     return top._RouteCall( "Liquid", "_isPrinters();" );
  99. }
  100.  
  101. function LTKGetKeyValue( KeyName, ValueName, Default )
  102. {
  103.     return top._RouteCall( "Liquid", "_LTKGetKeyValue('"+KeyName+"','"+ValueName+"','"+Default+"');" );
  104. }
  105.  
  106. function LTKGetIntKeyValue( KeyName, ValueName, Default )
  107. {
  108.     return top._RouteCall( "Liquid", "_LTKGetIntKeyValue('"+KeyName+"','"+ValueName+"','"+Default+"');" );
  109. }
  110.  
  111. function LTKSetKeyValue( KeyName, ValueName, Value )
  112. {
  113.     return top._RouteCall( "Liquid", "_LTKSetKeyValue('"+KeyName+"','"+ValueName+"','"+Value+"');" );
  114. }
  115.  
  116. function LTKSetIntKeyValue( KeyName, ValueName, Value )
  117. {
  118.     return top._RouteCall( "Liquid", "_LTKSetIntKeyValue('"+KeyName+"','"+ValueName+"','"+Value+"');" );
  119. }
  120.  
  121. // Logo
  122.  
  123. // ActivityList
  124.  
  125. function ALUpdateButton(Btn)
  126. {
  127.     return top._RouteCall( "ActivityList", "_ALUpdateButton("+Btn+");" );
  128. }
  129.  
  130. function ALClickButton(Btn)
  131. {
  132.     return top._RouteCall( "ActivityList", "_ALClickButton("+Btn+");" );
  133. }
  134.  
  135. function ALActivate(ID)
  136. {
  137.     return top._RouteCall( "ActivityList", "_ALActivate("+ID+");" );
  138. }
  139.  
  140.  
  141. // ToolKits
  142.  
  143. function TKUpdateButton(Btn)
  144. {
  145.     return top._RouteCall( "ToolKits", "_TKUpdateButton("+Btn+");" );
  146. }
  147.  
  148. function TKClickButton(Btn)
  149. {
  150.     return top._RouteCall( "ToolKits", "_TKClickButton("+Btn+");" );
  151. }
  152.  
  153. function TKSetMode( mode )
  154. {
  155.     return top._RouteCall( "ToolKits", "_TKSetMode("+mode+");" );
  156. }
  157.  
  158.  
  159. // Tools
  160.  
  161. function TUpdateButton()
  162. {
  163.     return top._RouteCall( "Tools", "_TUpdateButton();" );
  164. }
  165.  
  166. function TClickButton(Btn)
  167. {
  168.     return top._RouteCall( "Tools", "_TClickButton("+Btn+");" );
  169. }
  170.  
  171. function TClickButton2(Btn)
  172. {
  173.     return top._RouteCall( "Tools", "_TClickButton2("+Btn+");" );
  174. }
  175.  
  176. function TSetVisibility(Mask)
  177. {
  178.     return top._RouteCall( "Tools", "_TSetVisibility("+Mask+");" );
  179. }
  180.  
  181. // CommandBar
  182.  
  183. function CUpdateButton(Btn)
  184. {
  185.     return top._RouteCall( "CommandBar", "_CUpdateButton("+Btn+");" );
  186. }
  187.  
  188. function CClickButton(Btn)
  189. {
  190.     return top._RouteCall( "CommandBar", "_CClickButton("+Btn+");" );
  191. }
  192.  
  193. // ShelfBar
  194.  
  195. function SBUpdateButton(Btn)
  196. {
  197.     return top._RouteCall( "ShelfBar", "_SBUpdateButton("+Btn+");" );
  198. }
  199.  
  200. function SBClickButton(Btn)
  201. {
  202.     return top._RouteCall( "ShelfBar", "_SBClickButton("+Btn+");" );
  203. }
  204.  
  205. // WorkArea
  206.  
  207. // Shelves
  208.  
  209. function SSetShelfMode(Mode)
  210. {
  211.     return top._RouteCall( "Shelves", "_SSetShelfMode("+Mode+");" );
  212. }
  213.  
  214. function SUpdateShelves()
  215. {
  216.     return top._RouteCall( "Shelves", "_SUpdateShelves();" );
  217. }
  218.  
  219. // BuddyTools
  220.  
  221. function BTSetVisibility(Mask)
  222. {
  223.     return top._RouteCall( "BuddyTools", "_BTSetVisibility("+Mask+");" );
  224. }
  225.  
  226. function BTSetPaintMode(mode)
  227. {
  228.     return top._RouteCall( "BuddyTools", "_BTSetPaintMode("+mode+");" );
  229. }
  230.  
  231. // P_RightPaneA
  232.  
  233. function RPASetTarget(sNewTarget)
  234. {
  235.     var sFullPath;
  236.  
  237.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  238.  
  239.     // This is a hack for speed!
  240.     return top._RPASetTarget(sFullPath);
  241.     // Proper call should be:
  242.     // return top._RouteCall( "P_RightPaneA", "_RPASetTarget('"+sFullPath+"');" );
  243. }
  244.  
  245. // P_ToolKits
  246.  
  247. function TKSetTarget(sNewTarget)
  248. {
  249.     var sFullPath;
  250.  
  251.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  252.  
  253.     // This is a hack for speed!
  254.     return top._TKSetTarget(sFullPath);
  255.     // Proper call should be:
  256.     // return top._RouteCall( "P_ToolKits", "_TKSetTarget('"+sFullPath+"');" );
  257. }
  258.  
  259. // P_Tools
  260.  
  261. function TSetTarget(sNewTarget)
  262. {
  263.     var sFullPath;
  264.  
  265.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  266.  
  267.     return top._RouteCall( "P_Tools", "_TSetTarget('"+sFullPath+"');" );
  268. }
  269.  
  270. // P_CommandBar (?)
  271.  
  272. function CSetTarget(sNewTarget)
  273. {
  274.     var sFullPath;
  275.  
  276.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  277.  
  278.     return top._RouteCall( "P_CommandBar", "_CSetTarget('"+sFullPath+"');" );
  279. }
  280.  
  281. // P_WorkArea
  282.  
  283. function WSetTarget(sNewTarget,sWorkflow)
  284. {
  285.     var sFullPath;
  286.  
  287.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  288.  
  289.     return top._RouteCall( "P_WorkArea", "_WSetTarget('"+sFullPath+"','"+sWorkflow+"');" );
  290. }
  291.  
  292. // P_BuddyTools
  293.  
  294. function BTSetTarget(sNewTarget)
  295. {
  296.     var sFullPath;
  297.  
  298.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  299.  
  300.     return top._RouteCall( "P_BuddyTools", "_BTSetTarget('"+sFullPath+"');" );
  301. }
  302.  
  303.  
  304. ////////////////////////////////////////////////////////////////
  305. //
  306. //    String manipulation (All slashes are expected forward!)
  307. //
  308.  
  309. // Resolve a relative path to a base path
  310. function ResolvePath( sBasePath, sRelativePath )
  311. {
  312.     var sNewBasePath;
  313.     var sNewEndPath;
  314.  
  315.     var nLevelBack = 1;        // Fix for last backslash
  316.     var nCurrIdx = 0;
  317.  
  318.     var nTemp;
  319.  
  320.     // Start by removing the filename from sBasePath if present
  321.     sNewBasePath = sBasePath.substring(0, sBasePath.lastIndexOf("/")+1 );
  322.  
  323.     // Count the number of levels we must go back
  324.     while(1)
  325.     {
  326.         nTemp = sRelativePath.indexOf( "../", nCurrIdx );
  327.  
  328.         if( nTemp >= 0 )
  329.         {
  330.             nCurrIdx = nTemp + 3;    // "../".length;
  331.             nLevelBack += 1;
  332.         }
  333.         else
  334.         {
  335.             break;
  336.         }
  337.     }
  338.  
  339.     sNewEndPath = sRelativePath.substring( nCurrIdx, sRelativePath.length );
  340.  
  341.     // Go back
  342.     while( nLevelBack > 0 )
  343.     {
  344.         nTemp = sBasePath.lastIndexOf("/", sNewBasePath.length-1);
  345.         sNewBasePath = sNewBasePath.substring( 0, nTemp );
  346.         nLevelBack -= 1;
  347.     }
  348.  
  349.     // Return the value
  350.     return sNewBasePath + "/" + sNewEndPath;
  351. }
  352.             
  353.  
  354. ////////////////////////////////////////////////////////////////
  355. //
  356. //    Miscelaneous stuff
  357. //
  358.  
  359. function SmartJump( fTarget, sNewTarget )
  360. {
  361.     var sFullPath;
  362.  
  363.     sFullPath = ResolvePath( window.location.href, sNewTarget );
  364.  
  365.     if( fTarget.location.href != sFullPath )
  366.     {
  367.         fTarget.location.href = sFullPath;
  368.         return 1;
  369.     }
  370.  
  371.     return 0;
  372. }
  373.  
  374. // Absolute path version
  375. function SmartJumpAbs( fTarget, sNewTarget )
  376. {
  377.     if( fTarget.location.href != sNewTarget )
  378.     {
  379.         fTarget.location.href = sNewTarget;
  380.         return 1;
  381.     }
  382.  
  383.     return 0;
  384. }
  385.